﻿//===============================================================================================================
// System  : Sandcastle Tools - Sandcastle Tools Core Class Library
// File    : NonRenderedParentElement.cs
// Author  : Eric Woodruff  (Eric@EWoodruff.us)
// Updated : 03/05/2022
// Note    : Copyright 2022, Eric Woodruff, All rights reserved
//
// This file contains the class used to handle parent elements that do not themselves have any rendered
// representation.
//
// This code is published under the Microsoft Public License (Ms-PL).  A copy of the license should be
// distributed with the code and can be found at the project website: https://GitHub.com/EWSoftware/SHFB.  This
// notice, the author's name, and all copyright notices must remain intact in all applications, documentation,
// and source files.
//
//    Date     Who  Comments
// ==============================================================================================================
// 01/14/2022  EFW  Created the code
//===============================================================================================================

using System;
using System.Xml.Linq;

namespace Sandcastle.Core.PresentationStyle.Transformation.Elements
{
    /// <summary>
    /// This handles parent elements that do not themselves have any rendered representation.  It simply parses
    /// each of the child nodes in the given element if it has any and renders those as needed.
    /// </summary>
    public class NonRenderedParentElement : Element
    {
        #region Constructor
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <remarks>This element only contains child elements and has no title.  If it contains a title
        /// element, it will be ignored.</remarks>
        /// <param name="name">The element name</param>
        public NonRenderedParentElement(string name) : base(name)
        {
        }
        #endregion

        #region Methods
        //=====================================================================

        /// <inheritdoc />
        public override void Render(TopicTransformationCore transformation, XElement element)
        {
            if(transformation == null)
                throw new ArgumentNullException(nameof(transformation));

            if(element == null)
                throw new ArgumentNullException(nameof(element));

            foreach(var child in element.Nodes())
                transformation.RenderNode(child);
        }
        #endregion
    }
}
